package custom

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/layout"
	"fyne.io/fyne/v2/widget"
)

func NewEditingOption(infoText string, slider *EditingSlider, defaultValue float64) *fyne.Container {
	data := binding.BindFloat(&defaultValue)
	text := widget.NewLabel(infoText)
	value := widget.NewLabelWithData(binding.FloatToStringWithFormat(data, "%.0f"))
	slider.Bind(data)
	slider.Step = 1

	return container.NewVBox(
		container.NewHBox(
			text,
			layout.NewSpacer(),
			value,
		),
		slider,
	)
}
func NewEditingOptionWithSlider(infoText string, min, max float64, defaultValue float64, dragEndFunc func(float64)) *fyne.Container {
	slider := NewEditingSlider(min, max, dragEndFunc)
	data := binding.BindFloat(&defaultValue)
	text := widget.NewLabel(infoText)
	value := widget.NewLabelWithData(binding.FloatToStringWithFormat(data, "%.0f"))
	slider.Bind(data)
	slider.Step = 0.1
	return container.NewVBox(
		container.NewHBox(
			text,
			layout.NewSpacer(),
			value,
		),
		slider,
	)
}
